Object Ownership and Containment
نویسنده
چکیده
Object-oriented programming relies on inter-object aliases to implement data structures and other abstractions. Objects have mutable state, but it is when mutable state interacts with aliasing that problems arise. Through aliasing an object’s state can be changed without the object being aware of the changes, potentially violating the object’s invariants. This problem is fundamentally unresolvable. Many idioms such as the Observer design pattern rely on it. Hence aliasing cannot be eliminated from object-oriented programming, it can only be managed. Various proposals have appeared in the literature addressing the issue of alias management. The most promising are based on alias encapsulation, which limits access to objects to within certain well-defined boundaries. Our approach called ownership types falls into this category. An object can specify the objects it owns, called its representation, and which objects can access its representation. A type system protects the representation by enforcing a well-defined containment invariant. Our approach is a formal one. Ownership types are cast as a type system using an minor extension to Abadi and Cardelli’s object calculus with subtyping. With this formalisation we prove the soundness of our ownership types system and demonstrate that well-typed programs satisfy the containment invariant. In addition, we also provide a firm grounding to enable ownership types to be safely added to an objectoriented programming language with inheritance, subtyping, and nested classes, as well as offering a sound basis for future work. Our type system can model aggregate objects with multiple interface objects sharing representation and friendly functions which access multiple objects’ private representations, among other examples, thus overcoming weaknesses in existing alias management schemes. Sydney-Belgrade-Utrecht. July 1998-May 2001.
منابع مشابه
Simple Ownership Types for Object Containment
Containment of objects is a natural concept that has been poorly supported in object-oriented programming languages. For a prede ned set of ownership contexts, this paper presents a type system that enforces certain containment relationships for run-time objects. A xed ordering relationship is presumed between the owners. The formalisation of ownership types has developed from our work with exi...
متن کاملThe Geometry of Object
In object-oriented systems, it is often the case that an object will have an attribute whose value identiies (points or refers to) some other object in the system so that the identiied object can be sent messages. In general, there is no assumed geometric notion of relative location associated with such object references, e.g. when a bank customer references a bank account for the purposes of d...
متن کاملThe Ins and Outs of Objects
Aggregation and containment are important concepts in object-oriented modeling. In componentbased approaches to software development, aggregation and containment are touted as one of the primary mechanisms for component reuse. Containment relationships are typically implemented with object references in most object-oriented programming languages. This encourages sharing of component objects bet...
متن کاملThe Geometry of Object Containment 1
In object-oriented systems, it is often the case that an object will have an attribute whose value identiies (points or refers to) some other object in the system so that the identiied object can be sent messages. The association between objects determined by the object references in a system will generally result in a complex structure whose design and speciication is a crucial part of the dev...
متن کاملReflecting on Several Metaphors for Media Spaces
• a bounded space that affords partitioning into a collection of rooms; • containment within through individual rooms, where they collect people and groupware objects; • permeability of rooms allowing people and things to enter and leave them; • persistence of objects within the room over time; • socially mediated ownership that controls who should enter and use that room and how privacy is man...
متن کامل